<template>
	<body>
		<div class="loan_nav">
			<ul>
				<li>
					<a href="javascript:history.go(-1)">
						<i class="iconfont">&#xe61e;</i>
					</a>
				</li>
				<li>
					<p>注册</p>
				</li>
				<li></li>
			</ul>
		</div>
		<div class="login_flex">
		<div class="interval_T">

		</div>
		<div class="register_form">
			<!--
			<ul>
				<li>
					<p>姓名</p>
				</li>
				<li><input type="text" placeholder="请输入真实姓名" /></li>
				<li></li>
			</ul>
			-->
			<ul>
				<li>
					<p>手机号码</p>
				</li>
				<li><input v-model="params.mobile" type="tel" placeholder="中国大陆手机号" maxlength="11" /></li>
				<li></li>
			</ul>
			<ul>
				<li>
					<p>验证码</p>
				</li>
				<li><input v-model="params.randCode"  type="tel"  placeholder="请输入短信验证码" maxlength="6" /></li>
				<li><input @click="sendSms" type="button" value="发送验证码" class="col-db" /></li>
			</ul>
			<ul>
				<li>
					<p>登入密码</p>
				</li>
				<li><input v-model="params.password"  type="password"   placeholder="请设置登入密码" /></li>
				<li></li>
			</ul>
			<ul>
				<li>
					<p>确认密码</p>
				</li>
				<li><input v-model="password"  type="password"   placeholder="请确认密码" /></li>
				<li></li>
			</ul>
		</div>
		<ul class="read_contract">
			<li @click="showIcon = !showIcon">
				<div>
					<i class="iconfont" v-show="showIcon">&#xe67f;</i>
				</div>
				<p>本人已阅读并同意</p>
			</li>

			<li>
				<p>
					<router-link to="../agreement" class="col-db">《软件APP服务协议》</router-link>
				</p>
			</li>
		</ul>
		<div class="register_btn">
			<input @click="register" type="button" value="注册" class="register_submit" />
		</div>
		<div class="line_flex">

			</div>
		<div class="bottom_text">
			<p class="col_dg">软件APP版权归{{$root.orgInfo.companyName}}所有</p>
			<p class="col_dg">因为努力所以有价值</p>
		</div>
		</div>
	</body>
</template>

<script>
export default {
	data() {
		return {
			params: {
				codeType: 'register',
				randType: 'register'
			},
			password: '',
			showIcon: false,
			uid: this.$route.query.uid ? this.$route.query.uid : -1
		}
	},
	created() {
		console.log(this.uid)
	},
	methods: {
		sendSms() {
			this.$http.post('/app/randCode', this.params).then(json => {
				const { code } = json
				if(code === 0) {
					this.$vux.toast.show({ text: '发送成功' })
				}
			})
		},
		register() {
			if(this.password !== this.params.password) return this.$vux.toast.show({ text: '两次密码输入不一致', type: 'warn' })
			if(!this.showIcon) return this.$vux.toast.show({ text: '未同意协议', type: 'warn' })
			this.$http.post(`/app/register/${this.uid}`, this.params).then(json => {
				const { code } = json
				if(code === 0) {
					this.$vux.toast.show({ text: '注册成功' })
					this.$router.push('/login')
				}
			})
		}
	}
}
</script>

<style>

</style>